program project1;
{$i mplatform.inc}
{$ifdef win32}
{$ifndef VirtualPascal}
{$APPTYPE CONSOLE}
{$endif}
{$endif}

uses
  {$ifdef fpc}
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}{$endif}
  Classes,SysUtils, mGraphics, mControls, AdUtils,  mForms, mSets;
type

  { TForm1 }

  TForm1=class(TForm)
    ABtn:TCustomButton;
    procedure Form1OnResize(Sender:TObject);
    procedure Form1OnClick(Sender:TObject);
    procedure BOnClick(Sender:TObject);
  end;

{ TForm1 }

procedure TForm1.Form1OnResize(Sender: TObject);
begin
  Caption:='Форма '+IntToStr(Width)+', '+IntToStr(Height);
end;

procedure TForm1.Form1OnClick(Sender: TObject);
begin
  writeln('!!!');
end;

procedure TForm1.BOnClick(Sender: TObject);
begin
  writeln('Button!');
end;

var
    MSG:TMessage;
    F:TForm1;
begin
  F:=TForm1.Create(nil);
  Writeln(F.Handle);
//  Writeln(GetLastError);
  F.Left:=100;
  F.Top:=100;
  F.Width:=200;
  F.Height:=100;
  F.OnResize:=F.Form1OnResize;
  F.OnClick:=F.Form1OnClick;
  Writeln('Showing');
  F.Color:=clYellow;
  F.Show;

  Writeln('Showed');
  F.Caption:='Cap';
  F.ABtn:=TCustomButton.Create(F);
  with F.ABtn do
  begin
      Left:=10;
      Top:=10;
      Width:=50;
      Height:=50;
      Caption:='Btn';
      Color:=clGray;
      Parent:=F;
      F.ABtn.OnClick:=F.BOnClick;
      Show;
  end;

  Application.Run;
  Application.Done;
end.
